<?php
namespace App\Http\Controllers\API;
/**
 * Created by PhpStorm.
 * User: 都大爽
 * Date: 2017/7/31
 * Time: 17:51
 */
use App\Http\Controllers\Controller;
use App\Models\PropositionCompany;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;

class PropositionCompanyController extends Controller
{
    /**
     * 获取命题下拉列表
     * @param $awardId
     * @return array
     */
    public function getSelectList($awardId)
    {
        $list = [];
        $disabledIds = DB::table('award_company')->where('award_id', $awardId)->pluck('company_id')->toArray();
        $models = PropositionCompany::all();
        foreach ($models as $model) {
            if (in_array($model->id, $disabledIds)){
                $list[] = ['label' => $model->code . '-' . $model->name, 'value' => $model->id, 'isDisabled' => true];
            }else{
                $list[] = ['label' => $model->code . '-' . $model->name, 'value' => $model->id];
            }
        }
        return $list;
    }
}